package com.example.springbootdemo.controller;

import com.example.springbootdemo.config.Config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("")
public class IndexController {

    @Autowired
    Config config;

    @GetMapping("")
    public String index() {
        String r = String.format("spring boot demo v%s", config.getVersion());
        System.out.println(r);
        return r;
    }

    @GetMapping("/hello")
    public String hello() {
        return String.format("hello v%s", config.getVersion());
    }

    @GetMapping("/desc")
    public String desc() {
        return config.getDesc();
    }

    @GetMapping("/author")
    public String author() {
        return config.getAuthor();
    }

    @GetMapping("/info")
    public String info() {
        String r = String.format(
                "作者：%s<br/>名称：%s<br/>描述：%s<br/>版本：%s<br/>环境：%s"
                , config.getAuthor()
                , config.getName()
                , config.getDesc()
                , config.getVersion()
                , config.getEnv()
        );
        System.out.println(r);
        return r;
    }
}
